package main;

import graphinterface.ImageButton;

import org.newdawn.slick.*;
import org.newdawn.slick.state.*;
import org.newdawn.slick.state.transition.FadeInTransition;
import org.newdawn.slick.state.transition.FadeOutTransition;

import savesystem.MenuSecondaire;
import savesystem.PlayerStat;

public class Menu extends BasicGameState { 
	
	public static final int ID = 1;
	
	public PlayerStat ps;
	
	private ImageButton boutonP;
	private ImageButton boutonE;
	private ImageButton boutonC;
	
	public Menu(){	
	}
	
	public void init(GameContainer gc, StateBasedGame sbg) throws SlickException{
		SpriteSheet bouton = new SpriteSheet("res/bouton.png", 342, 26);
		boutonP = new ImageButton(bouton.getSprite(0, 1));
		boutonC = new ImageButton(bouton.getSprite(0, 2));
		boutonE = new ImageButton(bouton.getSprite(0, 3));
		
		new PlayerStat().generate();
	}
	
	public void render(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException{
		boutonP.drawCentered(g, gc.getWidth()/2, gc.getHeight()/2 + 50);
		boutonC.drawCentered(g, gc.getWidth()/2, gc.getHeight()/2 + 100);
		boutonE.drawCentered(g, gc.getWidth()/2, gc.getHeight()/2 + 150);
	}
	
	public void update(GameContainer gc, StateBasedGame sbg, int delta) throws SlickException{
		boutonP.update(gc, 0);
		boutonC.update(gc, 0);
		boutonE.update(gc, 0);

		if (boutonP.isPushed()){
			sbg.enterState(MenuSecondaire.ID, new FadeOutTransition(), new FadeInTransition());
			boutonP.resetPushed();
		}
		if (boutonC.isPushed()){
			boutonC.resetPushed();
		}
		if (boutonE.isPushed()){
			gc.exit();
		}
	}
	
	public int getID(){
		return ID;
	}
}
